package com.cjh.scala

/**
 * Created by Administrator on 2016/6/11 0011.
 */
class Basic6 {

}

class A {

}

class RichA(a: A) {
  def rich: Unit = {
    println("rich...")
  }
}

object Basic6 extends App {
  //  implicit def a2RichA(a:A)=new RichA(a) //隐式转换：将A转换成了RichA
  //  val a=new A
  //  a.rich

  def implicitTest(implicit name: String): Unit = {
    println(name)
  }

  //隐式参数
//  implicit val name = "BOBBBBB"
//  implicitTest
  //隐式类--为某一类扩展功能
  implicit class calculator(x:Int){
    def add(x:Int):Int=x+2
  }
  println(1.add(1))
}
